{% extends 'index.html' %}
{% block content %}
    <div class="breadcrumbs">
        <div class="breadcrumbs-inner">
            <div class="row m-0">
                <div class="col-sm-4">
                    <div class="page-header float-left">
                        <div class="page-title">
                            <h1>京乳时鲜 &emsp;&emsp;&emsp;车辆管理系统&emsp;&emsp;</h1>
                        </div>
                    </div>
                </div>
                <div class="col-sm-8">
                    <div class="page-header float-right">
                        <div class="page-title">
                            <ol class="breadcrumb text-right">
                                <li><a href="{% url 'index' %}">主页</a></li>
                                <li><a href="{% url 'truck_asset_manage' %}">车辆资产管理</a></li>
                                <li class="active" >生成车辆需求单</li>
                            </ol>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="content row">
        <div class="col-lg-9">
            <div class="card">
                <div class="card-header">
                    <strong class="card-title">车辆需求单</strong>
                </div>
                <div class="card-body">
                    <table class="table">
                        <thead class="thead-dark">
                            <tr>
                              <th scope="col">序号</th>
                              <th scope="col">车辆型号</th>
                              <th scope="col">所需数量</th>
                              <th scope="col">产生时间</th>
                          </tr>
                      </thead>
                      <tbody>
                            {% for item in real_need %}
                            <tr>
                                <th scope="row">{{ item.pattern_id }}</th>
                                <td>{{ item.truck_pattern }}</td>
                                <td>{{ item.truck_num }}</td>
                                <td>{{ item.statistics_time|date:"Y-m-d H:m:s"}}</td>
                            </tr>
                            {% endfor %}
                    </tbody>
                </table>
                </div>
            </div>
        </div>
        <div class="col-lg-3">
            <div class="card">
                <div class="card-header">
                    <strong>附加信息</strong>
                </div>
                <div class="card-body">
                    <!-- Credit Card -->
                    <div id="pay-invoice">
                        <div class="card-body">
                            <div class="card-title">
                                <h4 class="text-center">附加信息填写</h4>
                            </div>
                            <hr>
                            <form action="#" method="POST" novalidate="novalidate">
                                {% csrf_token %}
                                <div class="form-group">
                                    <label for="cc-payment" class="control-label mb-1">选择车辆供应商</label>
                                    <select class="form-control" name="where" type="truck_sup">
                                        <option>一汽车厂</option>
                                        <option>比亚迪车厂</option>
                                        <option>丰田车厂</option>
                                        <option>奔驰车厂</option>
                                        <option>长城车厂</option>
                                    </select>
                                </div>
                                <div class="form-group has-success">
                                    <label for="cc-name" class="control-label mb-1">选择车型</label>
                                    <select class="form-control" name="truck_pattern" type="truck_pattern">
                                        <option value="全选">全选</option>
                                        {% for item in real_need %}
                                            <option value="{{ item.truck_pattern }}">{{ item.truck_pattern }}</option>
                                        {% endfor %}
                                    </select>
                                </div>
                                <div class="text-sm-center">
                                    <input value="提交需求单" type="submit" class="btn btn-primary" width="20"/>
                                </div>
                            </form>
                        </div>
                    </div>

                </div>
            </div>

        </div>
    </div>


<script>
    jQuery(document).ready(function ($) {
        $("#trucks").addClass("active");
        $("#truck_asset_manange").addClass("active");
        $("#trucks_toggle").trigger("click");
    })
    $("button").click(function () {
        var this_row = this;
        $.ajax({
            url: "",
            type: "GET",
            data: {"type":$(this_row).attr("type"), "truck_pattern":this_row.name},
            success: function (data) {
                if (data.result==="success"){
                    $(this_row).parent().parent().addClass("sel");
                    table.rows(".sel").remove().draw(false);
                }
            }
        });
    });

</script>
{% endblock %}